package 多线程.Test;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Test03 {
    public static void main(String[] args) {
        //内部类
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    Date currentTime = new Date();
                    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    String formattedTime = formatter.format(currentTime);
                    System.out.println("时间：" +formattedTime);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

        //lambda
        new Thread( ()->{
            while (true){
                int i = 0;
                while (true){
                    System.out.println("数字：" + ++i);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }
}
